#pragma once

#include "D3DUtils.h"
#include "Component.h"
#include "Shape.h"
#include "Rect.h"

class Sprite :
	public Component
{
public:
	Sprite();
	Sprite(std::string path);
	Sprite(std::string path, float _posX, float _posY);
	
	virtual ~Sprite();

	void SetPosition(float x, float y);
	void SetPositionX(float x);
	void SetPositionY(float y);
	void SetScale(float x, float y) { transform->SetScale(x, y); return; }
	void SetScaleX(float x) { transform->SetScaleX(x); return; }
	void SetScaleY(float y) { transform->SetScaleY(y); return; }
	void SetCenter(float, float);
	void SetSrcRect(RECT& srcRect);

	D3DXVECTOR3 GetPosition()
	{
		Vector2D v;
		transform->GetPosition(&v);
		D3DXVECTOR3 r;
		r.x = v.x;
		r.y = v.y;
		return r;
	}
	float GetPositionX() { return transform->GetX(); }
	float GetPositionY() { return transform->GetY(); }

	void SetRotationY(float angleY){ return; }
	void SetRotationX(float angleX){ return; }
	void SetRotationZ(float angleZ){ transform->SetRotation(angleZ); }
	void SetRotationYawPitchRoll(float yaw, float pitch, float roll){ return; }
	
	bool Sprite::SetTexture(const char *szTextureFilePath, D3DCOLOR dwKeyColour);
	
	virtual void Update(float dt);
	virtual void Draw(ID3DXSprite* sprite, D3DXMATRIX& view, D3DXMATRIX& proj);

protected:
	void LoadTexture(std::string path);
	bool isVisible;

	IDirect3DTexture9* mTexture;
	D3DXVECTOR3 mCenter;
	// D3DXVECTOR3 mPosition;
	RECT srcRect;
	D3DXIMAGE_INFO imgInfos;
	// D3DXMATRIX mTranslation;
	// D3DXMATRIX mRotation;
	// D3DXMATRIX S;

	Transform* transform;
	// Shape* collider;
};
